//
//  LBNormalBlendColorFilter.mm
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 3/29/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#include "LBNormalBlendColorFilter.h"
#include "LBGraphics.h"
char fShaderStrNormalBlendColor[] = ""
"precision mediump float;"

"varying vec2 vtexCoor;"
"varying vec4 vposition;"
"uniform sampler2D texture;"
"uniform vec4 color;"
"uniform float opacity;"


"void main()"
"{"
"    lowp vec4 textureColor = texture2D(texture, vtexCoor);"
"    textureColor = mix(textureColor, color, opacity);"
"    gl_FragColor = textureColor;"
"}";

LBNormalBlendColorFilter::LBNormalBlendColorFilter(){
    init(0, fShaderStrNormalBlendColor);
    LBGraphics::getInstance()->useProgram(program);
    colorUniform = program->uniformIndex("color");
    opacityUniform = program->uniformIndex("opacity");
    setColor(1.0f, 1.0f, 1.0f);
    setOpactiy(1.0f);
}